<?php
	class giaoviendb
	{
		public function Add($MaGiaoVien,$TenGiaoVien,$DiaChi,$DienThoai,$Email,$Phai,$NgaySinh)
		{
			$sql = "INSERT INTO `tbl_giaovien`(`MaGiaoVien`, `TenGiaoVien`, `DiaChi`, `DienThoai`, `Email`, `Phai`, `NgaySinh`) 
			VALUES ('$MaGiaoVien',".dataservice::slashes($TenGiaoVien).",".dataservice::slashes($DiaChi).",'$DienThoai','$Email','$Phai',".dataservice::slashes($NgaySinh).")";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($MaGiaoVien)
		{
			$sql = "DELETE FROM `tbl_giaovien` WHERE MaGiaoVien = '$MaGiaoVien' ";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Update($MaGiaoVien,$TenGiaoVien,$DiaChi,$DienThoai,$Email,$Phai,$NgaySinh)
		{
			$sql = "UPDATE `tbl_giaovien`
			 SET TenGiaoVien = ".dataservice::slashes($TenGiaoVien).",
				 DiaChi = ".dataservice::slashes($DiaChi).",
				 DienThoai = '$DienThoai',
				 Email = '$Email',
				 Phai = '$Phai',
				 NgaySinh = '$NgaySinh'
			 WHERE MaGiaoVien = '$MaGiaoVien'"; 
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
	
	
		public function GetList($MaGiaoVien,$TenGiaoVien,$DiaChi,$DienThoai,$Email,$Phai,$NgaySinh)
		{
			$sql = "SELECT * FROM `tbl_giaovien` WHERE 1";
			if($MaGiaoVien!="")
				$sql .= " AND MaGiaoVien = '$MaGiaoVien' ";
			if($TenGiaoVien!="")
				$sql .= " AND TenGiaoVien = '$TenGiaoVien' ";
			if($DiaChi!="")
				$sql .= " AND DiaChi = '$DiaChi' ";
			if($DienThoai!="")
				$sql .= " AND DienThoai = '$DienThoai' ";
			if($Email!="")
				$sql .= " AND Email = '$Email' ";
			if($Phai!="")
				$sql .= " AND Phai = '$Phai' ";
			if($NgaySinh!="")
				$sql .= " AND NgaySinh = '$NgaySinh' ";			
			$sql .= " ORDER BY  MaGiaoVien DESC ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		public function Find($MaGiaoVien,$TenGiaoVien,$DiaChi,$DienThoai,$Email,$Phai,$NgaySinh)
		{
			$sql = "SELECT * FROM `tbl_giaovien` WHERE 1";
			if($MaGiaoVien!="")
				$sql .= " AND MaGiaoVien LIKE '%$MaGiaoVien%' ";
			if($TenGiaoVien!="")
				$sql .= " AND TenGiaoVien LIKE '%$TenGiaoVien%' ";
			if($DiaChi!="")
				$sql .= " AND DiaChi LIKE '%$DiaChi%' ";
			if($DienThoai!="")
				$sql .= " AND DienThoai LIKE '%$DienThoai%' ";
			if($Email!="")
				$sql .= " AND Email LIKE '%$Email%' ";
			if($Phai!="")
				$sql .= " AND Phai = '$Phai' ";
			if($NgaySinh!="")
				$sql .= " AND NgaySinh LIKE '%$NgaySinh%' ";			
			$sql .= " ORDER BY  MaGiaoVien DESC ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
	}
?>